home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCDEF_H
- #define FWEXCDEF_H
- //========================================================================================
- //
- // File: FWExcDef.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #ifndef FWONSTAC_H
- #include "FWOnStac.h"
- #endif
-
- #ifndef FWCLAINF_H
- #include "FWClaInf.h"
- #endif
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWTRYBLO_H
- #include "FWTryBlo.h"
- #endif
-
- #ifndef FWEXCRUN_H
- #include "FWExcRun.h"
- #endif
-
- #ifndef FWDELSTA_H
- #include "FWDelSta.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BAD_CODE_GENERATION
- int ReturnFalse();
- int ReturnTrue();
- #define FW_BEL_FALSE ::ReturnFalse()
- #define FW_BEL_TRUE ::ReturnTrue()
- #else
- #define FW_BEL_FALSE 0
- #define FW_BEL_TRUE 1
- #endif
-
- //========================================================================================
- // Exception Handling Interface Macros
- //========================================================================================
-
- #define FW_VOLATILE(a) ((void) &a)
-
- #ifdef FW_NATIVE_EXCEPTIONS
-
- // --------------- Native exceptions
-
- #define FW_TRY \
- try
-
- #define FW_CATCH_BEGIN
-
- #define FW_CATCH(class, error) \
- catch(class error)
-
- #define FW_CATCH_REFERENCE(class, error) \
- catch(class& error)
-
- #define FW_CATCH_NO_INSTANCE(class) \
- catch(class)
-
- #define FW_CATCH_EVERYTHING() \
- catch(...)
-
- #define FW_CATCH_END
-
- #define FW_THROW(error) throw error
- #define FW_THROW_SAME() throw
- #define FW_THROWS_NOTHING() // we don't support this in emulation anyhow...
- #define FW_THROWS(class) // we don't support this in emulation anyhow...
-
- #define FW_END_CONSTRUCTOR
- #define FW_START_DESTRUCTOR
- #define FW_NEW(class, args) new class##args
-
- #define FW_AUTO_DESTRUCT_OBJECT
- #define FW_AUTO_DESTRUCT_MIXIN
- #define FW_EXCEPTION_OBJECT
-
- #elif !defined FW_DISABLE_EXCLIB
-
- // --------------- Exception emulation library
-
-
- #ifdef FW_USE_NEW_HELPER
-
- class FW_CPrivNewHelper;
-
- #ifdef __MWERKS__
-
- extern const FW_CPrivNewHelper& _FW_MetrowerksHack(const FW_CPrivNewHelper&);
-
- #define FW_NEW(class, args) (class*) \
- ( \
- (new(_FW_MetrowerksHack(FW_CPrivNewHelper(::operator new, ::operator delete))) class##args), \
- ((void*) FW_CPrivNewHelper::PopNewHelper()->ForgetObject()) \
- )
-
- #else
-
- #define FW_NEW(class, args) (class*) \
- ( \
- (new(FW_CPrivNewHelper(::operator new, ::operator delete)) class##args), \
- ((void*) FW_CPrivNewHelper::PopNewHelper()->ForgetObject()) \
- )
- #endif
-
- #else
- #define FW_NEW(class, args) new class##args
- #endif
-
- #define FW_SAVE_TRACE_STATE
- #define FW_RESTORE_TRACE_STATE
-
- #define FW_TRY \
- { \
- FW_SPrivExceptionGlobals& __excGlobals = FW_CExceptionTaskGlobals::GetExceptionGlobals(); \
- FW_SAVE_TRACE_STATE \
- jmp_buf __jumpBuffer; \
- if(setjmp(__jumpBuffer) == 0) \
- { \
- FW_CPrivTryBlockContext __context(__excGlobals, __jumpBuffer);
-
- #define FW_CATCH_BEGIN \
- } \
- else \
- { \
- FW_RESTORE_TRACE_STATE \
- if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH(class, error) \
- } \
- else if (__excGlobals.gThrownException->PrivIsKindOf(FW_CLASS_INFO_PTR(class))) \
- { \
- class error = * (class*) __excGlobals.gThrownException; \
- FW_CPrivExceptionRuntime::CaughtException(__excGlobals, &error);
-
- #define FW_CATCH_REFERENCE(class, error) \
- } \
- else if (__excGlobals.gThrownException->PrivIsKindOf(FW_CLASS_INFO_PTR(class))) \
- { \
- class & error = *(class*) __excGlobals.gThrownException; \
- FW_CPrivExceptionRuntime::CaughtReferenceException(__excGlobals);
-
- #define FW_CATCH_NO_INSTANCE(class) \
- } \
- else if (__excGlobals.gThrownException->PrivIsKindOf(FW_CLASS_INFO_PTR(class))) \
- { \
- FW_CPrivExceptionRuntime::CaughtNoInstanceException(__excGlobals);
-
- #define FW_CATCH_EVERYTHING() \
- } \
- else if (FW_BEL_TRUE) \
- { \
- FW_CPrivExceptionRuntime::CaughtEverythingException(__excGlobals);
-
- #define FW_CATCH_END \
- } \
- else \
- { \
- FW_CPrivExceptionRuntime::KeepThrowing(__excGlobals); \
- } \
- FW_CPrivExceptionRuntime::CatchCleanup(__excGlobals); \
- } \
- }
-
- #define FW_THROW(error) \
- FW_CPrivExceptionRuntime::Throw(error)
-
- #define FW_THROW_SAME() \
- FW_CPrivExceptionRuntime::ThrowSame()
-
- #define FW_THROWS_NOTHING() \
- FW_CPrivThrowGuard __nothing
-
- #define FW_THROWS(class) \
- FW_CPrivThrowGuard __nothing##class(FW_CLASS_INFO_PTR(class))
-
- #ifdef FW_USE_NEW_HELPER
- #define FW_END_CONSTRUCTOR \
- FW_CPrivExceptionRuntime::EndConstructor(this, sizeof(*this));
- #define FW_START_DESTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- FW_CPrivDeleteStack::PopIfTopEquals(this);
- #else
- #define FW_END_CONSTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- FW_CPrivDeleteStack::Push(this);
- #define FW_START_DESTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- FW_CPrivDeleteStack::PopIfTopEquals(this);
- #endif
-
- #define FW_AUTO_DESTRUCT_OBJECT : public _FW_CAutoDestructObject
- #define FW_AUTO_DESTRUCT_MIXIN public _FW_CAutoDestructObject,
- #define FW_EXCEPTION_OBJECT : public _FW_XException
-
- #else
-
- // --------------- Exceptions are turned off
-
- #define FW_TRY \
- { \
- if(FW_BEL_TRUE) \
- {
-
- #define FW_CATCH_BEGIN \
- } \
- else \
- { \
- if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH(class, error) \
- } \
- else if (FW_BEL_FALSE) \
- { \
- class error = * (class*) 0;
-
- #define FW_CATCH_REFERENCE(class, error) \
- } \
- else if (FW_BEL_FALSE) \
- { \
- class & error = *(class*) 0;
-
- #define FW_CATCH_NO_INSTANCE(class) \
- } \
- else if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH_EVERYTHING() \
- } \
- else if (FW_BEL_TRUE) \
- {
-
- #define FW_CATCH_END \
- } \
- else \
- { \
- } \
- } \
- }
-
- #define FW_THROW(error) FW_DEBUG_MESSAGE(#error)
- #define FW_THROW_SAME()
- #define FW_THROWS_NOTHING()
- #define FW_THROWS(class)
-
- #define FW_END_CONSTRUCTOR
- #define FW_START_DESTRUCTOR
- #define FW_NEW(class, args) new class##args
-
- #define FW_AUTO_DESTRUCT_OBJECT
- #define FW_AUTO_DESTRUCT_MIXIN
- #define FW_EXCEPTION_OBJECT
-
- #endif
-
- //========================================================================================
- // Exception Logging Macros
- //========================================================================================
-
- #define FW_LOG_OR_TRIGGER_EXCEPTION(class, instance)
- #define FW_CAUSE_EXCEPTION_BY_NAME(name)
- #define FW_CAUSE_EXCEPTION_BY_COUNT(count)
-
- //========================================================================================
- // Exception Testing Macros
- //========================================================================================
-
- #ifdef FW_DEBUG
- #define FW_DECLARE_THROW_POINT(NAME) FW_CExceptionThrowPoint FW_g##NAME##ThrowPoint (#NAME)
- #define FW_CHECK_THROW_POINT(NAME) FW_g##NAME##ThrowPoint.Check ()
- #else
- #define FW_DECLARE_THROW_POINT(NAME)
- #define FW_CHECK_THROW_POINT(NAME)
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-